package com.ruibang.glass.purchase.controller;


import com.ruibang.glass.purchase.domain.req.PurchaseOrderReq;
import com.ruibang.glass.purchase.entity.PurchaseOrderDetails;
import com.ruibang.glass.purchase.mapper.PurchaseRelatedProductMapper;
import com.ruibang.glass.purchase.service.PurchaseOrderDetailsService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 采购订单
 * @author mameng
 */
@Api(tags = "采购订单")
@RestController
@RequestMapping("/api/glass/purchase/order")
public class PurchaseOrderDetailsController {


    @Autowired
    private PurchaseOrderDetailsService purchaseOrderDetailsService;

    @Autowired
    private PurchaseRelatedProductMapper purchaseRelatedProductMapper;


    @PostMapping("/list")
    @ApiOperation(value = "采购订单列表", response = ResultBody.class)
    public ResultBody queryAreas(@RequestBody PurchaseOrderReq purchaseReportReq) {
        return ResultBody.success(purchaseOrderDetailsService.getPage(purchaseReportReq));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "评标报告修改", response = ResultBody.class)
    public ResultBody edit(@RequestBody PurchaseOrderDetails gProcureBidEvaluationReports) {
        purchaseOrderDetailsService.updatePurchaseOrderDetails(gProcureBidEvaluationReports);
        return ResultBody.success();
    }

    @GetMapping("/getOne/{id}")
    @ApiOperation(value = "评标报告获取对象", response = ResultBody.class)
    public ResultBody getOne(@PathVariable("id") String id) {
        return ResultBody.success(purchaseOrderDetailsService.getPurchaseOrderDetails(id));
    }

    //
    @GetMapping("/removeOne/{id}")
    @ApiOperation(value = "删除商品", response = ResultBody.class)
    public ResultBody removeOne(@PathVariable("id") String id) {
        purchaseRelatedProductMapper.deleteById(id);
        return ResultBody.success();
    }


    @PostMapping("/addPurchaseArrOrder")
    @ApiOperation(value = "添加采购到货单", response = ResultBody.class)
    public ResultBody addPurchaseArrOrder(@RequestBody PurchaseOrderDetails gProcureBidEvaluationReports) {
        purchaseOrderDetailsService.addPurchaseArrOrder(gProcureBidEvaluationReports);
        return ResultBody.success();
    }

    @PostMapping("/updatePayStatus")
    @ApiOperation(value = "更改支付状态", response = ResultBody.class)
    public ResultBody updatePayStatus(@RequestBody PurchaseOrderDetails gProcureBidEvaluationReports) {
        purchaseOrderDetailsService.updatePayStatus(gProcureBidEvaluationReports);
        return ResultBody.success();
    }

    @PostMapping("/updateOverStatus")
    @ApiOperation(value = "更改结束状态", response = ResultBody.class)
    public ResultBody updateOverStatus(@RequestBody PurchaseOrderDetails gProcureBidEvaluationReports) {
        purchaseOrderDetailsService.updateOverStatus(gProcureBidEvaluationReports);
        return ResultBody.success();
    }


}
